home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / sub_r < prev    next >
Encoding:
Text File  |  1994-12-20  |  829 b   |  39 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Principal submatrix.
  4.  
  5. // Syntax:    sub ( A , i , j )
  6. //        sub ( A, i )
  7.  
  8. // Description:
  9.  
  10. //    sub(A,i,j)  is A(i:j,i:j).
  11.  
  12. //      sub(A,i) is the leading principal submatrix of order i,
  13. //    A[1:i;1:i], if i>0, and the trailing principal submatrix of
  14. //    order ABS(i) if i<0. 
  15.  
  16. //    This file is a translation of sub.m from version 2.0 of
  17. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  18. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  19.  
  20. //-------------------------------------------------------------------//
  21.  
  22. sub = function ( A , i , j )
  23. {
  24.   if (!exist (j))
  25.   {
  26.     if (i >= 0)
  27.     {
  28.       S = A[1:i; 1:i];
  29.     else
  30.       n = min(size(A));
  31.       S = A[n+i+1:n; n+i+1:n];
  32.     }
  33.   else
  34.     S = A[i:j; i:j];
  35.   }
  36.  
  37.   return S;
  38. };
  39.